<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
*{margin:0;padding:0;}

</style>
</head>

<body>
<div id="myDiv"></div>
	<script>
   
		//封装
		/*function loadScript(url){
			
			var script=document.createElement('script');
		
			script.type='text/javascript';
			
			script.src=url;
			
			document.body.appendChild(script);
		};
		
		loadScript('client.js');
		
		var script=document.createElement('script');
		
		script.type='text/javascript';
		//IE8-不支持
		script.appendChild(document.createTextNode('function sayHi(){alert("hello");}'));
		
		document.body.appendChild(script);*/
		
		/*var script=document.createElement('script');
		
		script.type='text/javascript';
		
		//safari 3.0之前的版本不支持
		script.text='function sayHi(){alert("hello");};';
		
		document.body.appendChild(script);*/
		
		//兼容所有浏览器
		function loadScriptString(code){
			
			var script=document.createElement('script');
		
			script.type='text/javascript';
			
			try{
				script.appendChild(document.createTextNode(code));
				
			}catch(ex){
				script.text=code;
			}
			
			document.body.appendChild(script);	
		};
		
		loadScriptString('function sayHi(){alert("hello");};');
		
		
    </script>
</body>
</html>
